#ifndef __YHM_SHARED_H__
#define __YHM_SHARED_H__

#include <infiniband/verbs.h>

/*
 delcare of req res struct
*/
enum {
  REQ_alloc_dsm = 100, // alloc new dsm
  REQ_write_trans_begin, //begin write trans
  REQ_write_trans_end,
  REQ_read_trans_begin, //begin read trans
  REQ_read_trans_end,
  REQ_page_get_read_addr, //get one addr of a address
  REQ_page_get_write_addr,
};
enum{
  RES_success = 100, //request successed
  RES_onfound, //request nofound
  RES_exist, //already exist
  RES_nomem, //no space
};

#define MAX_AGGR_PFN 3
struct m32{char m[32];};
struct req_struct{
  unsigned type;
  unsigned req_id;
  union{
    struct{ //for new dsm
      unsigned long size : 48;
      unsigned long mp_id : 16;
    }alloc_dsm;
    struct {
      unsigned long start;
      unsigned long end;
    }trans_write;
    struct {
      unsigned short mp_id;
    }trans_read;
    struct {
      unsigned long commit_id;
    }commit;
    struct {
      unsigned mp_id : 16;
      unsigned pad : 16;
      unsigned pfn[MAX_AGGR_PFN]; //end is -1
    }get_addr;
  };
};
union req_union{
  struct req_struct req;
  struct m32 _m32;
};

struct res_struct{
  unsigned req_id;
  unsigned status;
  union{
    unsigned long data[MAX_AGGR_PFN]; //return addr
    unsigned long commit_id; //return trans id;
  };

};
union res_union{
  struct res_struct res;
  struct m32 _m32;
};

#endif